<template>
  <div>
    <el-row :span="8" v-for="(page, index) of pages" :key="index" type="flex" style="margin-bottom: 10px">
      <el-col :span="6" v-for="(item, innerindex) of page" :key="item.id" :offset="innerindex > 0 ? 2 : 1">
        <ClubCard :club-record="item"></ClubCard>
      </el-col>
    </el-row>
  </div>

</template>

<script>
  import {getAllClubByStatus} from '../../api/club.js';
  import ClubCard from './clubmanage/ClubCard.vue'
export default {
  name: 'Welcome',
  data() {
    return {
      clubList: [],
    }
  },
  components: {
    ClubCard
  },
  created() {
    this.getClubList();
  },
  computed: {
    pages() {
      const pages = []
      this.clubList.forEach((item, index) => {
        const page = Math.floor(index / 3)//4代表4条为一行，随意更改
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  },
  methods: {
    getClubList() {
      getAllClubByStatus({
        status: 1,
      }).then(res=>{
        this.clubList = res.data;
      })
    }
  }
}
</script>

<style scoped>

  .clubCardList{
    display: flex;

  }
</style>
